public class Equition {
    int a;
    int b;
    int c;
    double result1;
    double result2;

    Equition(int a, int b, int c){
        this.a = a;
        this.b = b;
        this.c = c;
    }

    boolean calcuate() {
        boolean rst = false;
        if (a == 0) {
            System.out.println("这不是一元二次方程。");
        } else if (b * b - 4 * a * c < 0) {
            System.out.println("此一元二次方程无解。");
        } else {
            result1 = (-b - Math.sqrt(b * b - 4 * a * c)) / (2 * a);
            result2 = (-b + Math.sqrt(b * b - 4 * a * c)) / (2 * a);
            rst = true;
        }
        return rst;
    }
    void print(){
        System.out.println("x1=" + result1);
        System.out.println("x2=" + result2);
    }
}
